package com.norbitltd.guavaleaves.java.util;

import java.util.Collection;

import com.google.common.base.Function;

public class CollectionFunctions {

	
	public static <T> Function<Collection<T>, Integer> size() {
		return new Function<Collection<T>, Integer>() {
			public Integer apply(Collection<T> input) {
				return input.size();
			}
		};
	}
	
	public static <T> Function<Collection<T>, T[]> toArray() {
		return new Function<Collection<T>, T[]>() {
			@SuppressWarnings("unchecked")
			public T[] apply(Collection<T> input) {
				return (T[])input.toArray();
			}
		};
	}
}
